const num = 10000000;

console.log(num.toLocaleString());

function toPrice(num) {
  // return num.toString().replace(/(\d)(?=(\d{3})+\.)/g, '$1,')
  return num.toString().replace(/(\d)(?=(\d{3})+\.)/g, function (n) {
    console.log(n);
    return n + ",";
  });
}

console.log(toPrice(4123123.343434));
